﻿// Decompiled with JetBrains decompiler
// Type: UnityEngine.Rendering.DepthState
// Assembly: UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: E6AE6B5A-2752-4B07-9528-C8B77C62CE79
// Assembly location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.dll
// XML documentation location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.xml

using System;

#nullable disable
namespace UnityEngine.Rendering
{
  /// <summary>
  ///   <para>Values for the depth state.</para>
  /// </summary>
  /// <summary>
  ///   <para>Creates a new depth state with the given values.</para>
  /// </summary>
  /// <param name="writeEnabled">Controls whether pixels from this object are written to the depth buffer.</param>
  /// <param name="compareFunction">How should depth testing be performed.</param>
  public struct DepthState(bool writeEnabled = true, CompareFunction compareFunction = CompareFunction.Less) : 
    IEquatable<DepthState>
  {
    private byte m_WriteEnabled = Convert.ToByte(writeEnabled);
    private sbyte m_CompareFunction = (sbyte) compareFunction;

    /// <summary>
    ///   <para>Default values for the depth state.</para>
    /// </summary>
    public static DepthState defaultValue => new DepthState();

    /// <summary>
    ///   <para>Controls whether pixels from this object are written to the depth buffer.</para>
    /// </summary>
    public bool writeEnabled
    {
      get => Convert.ToBoolean(this.m_WriteEnabled);
      set => this.m_WriteEnabled = Convert.ToByte(value);
    }

    /// <summary>
    ///   <para>How should depth testing be performed.</para>
    /// </summary>
    public CompareFunction compareFunction
    {
      get => (CompareFunction) this.m_CompareFunction;
      set => this.m_CompareFunction = (sbyte) value;
    }

    public bool Equals(DepthState other)
    {
      return (int) this.m_WriteEnabled == (int) other.m_WriteEnabled && (int) this.m_CompareFunction == (int) other.m_CompareFunction;
    }

    public override bool Equals(object obj)
    {
      return obj != null && obj is DepthState other && this.Equals(other);
    }

    public override int GetHashCode()
    {
      return this.m_WriteEnabled.GetHashCode() * 397 ^ this.m_CompareFunction.GetHashCode();
    }

    public static bool operator ==(DepthState left, DepthState right) => left.Equals(right);

    public static bool operator !=(DepthState left, DepthState right) => !left.Equals(right);
  }
}
